package com.itheima.d1_collection_set;

import java.util.HashSet;
import java.util.Set;

/*
     目标：自定义的类型的对象，比如两个内容一样的学生对象，如果让HashSet集合能够去重复！
 */
public class SetTest3 {
    public static void main(String[] args) {
        Set<Student> studentSet = new HashSet<>();

        Student str1 = new Student("夏明", 19);
        Student str2 = new Student("夏雪", 20);
        Student str3 = str1;
        Student str4 = new Student("夏明", 19);


        studentSet.add(str1);
        studentSet.add(str2);
        studentSet.add(str3);
        studentSet.add(str4);

        for (Student student : studentSet) {
            System.out.println(student.toString());
        }
    }
}
